package io.kiki.stack.netty.command;

import io.kiki.stack.netty.invoker.RpcCommandType;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.net.InetSocketAddress;

@Slf4j
@Setter
@Getter
public class ResponseCommand extends AbstractCommand {
    private static final long serialVersionUID = 1L;
    private ResponseType responseType;
    private long responseTimeMillis;
    private InetSocketAddress responseHost;
    private Throwable cause;

    public ResponseCommand() {
        super(RpcCommandType.RESPONSE);
    }

    public ResponseCommand(CommandCode code) {
        super(RpcCommandType.RESPONSE, code);
    }

    public ResponseCommand(int id) {
        super(RpcCommandType.RESPONSE);
        this.setId(id);
    }

    public ResponseCommand(CommandCode code, int id) {
        super(RpcCommandType.RESPONSE, code);
        this.setId(id);
    }

    public ResponseCommand(byte version, byte type, CommandCode code, int id) {
        super(type, code);
        this.setId(id);
    }

    public long getResponseTimeMillis() {
        return responseTimeMillis;
    }

    public void setResponseTimeMillis(long responseTimeMillis) {
        this.responseTimeMillis = responseTimeMillis;
    }

    public InetSocketAddress getResponseHost() {
        return responseHost;
    }

    public void setResponseHost(InetSocketAddress responseHost) {
        this.responseHost = responseHost;
    }

    public ResponseType getResponseStatus() {
        return responseType;
    }

    public void setResponseStatus(ResponseType responseType) {
        this.responseType = responseType;
    }

    public Throwable getCause() {
        return cause;
    }

    public void setCause(Throwable cause) {
        this.cause = cause;
    }

}
